using System;
using System.Globalization;
using System.Windows.Data;

namespace LayoutPlanning.Converters
{
    public class TimeSpanToDouble:IValueConverter
    {
       
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is TimeSpan)
            {
                return ((TimeSpan) value).TotalSeconds;
            }
            return 0;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is double)
            {
                return TimeSpan.FromSeconds((value as double?)??0);
            }
            return TimeSpan.Zero;
        }
    }
}